home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl
-
- my $ROOT_DIR = $ARGV[0];
- my $DATA_FILE = $ARGV[1];
-
- open (FILE, $DATA_FILE) || die ;
-
- while (defined ($deleteme = <FILE>)) {
- chomp $deleteme;
- # system("/bin/rm -rf \"" . $ROOT_DIR . $deleteme . "\"");
- if (length($deleteme) > 0)
- {
- deleteTree($ROOT_DIR . $deleteme);
- }
- }
-
- sub deleteTree
- {
- my $path = $_[0];
-
- if (-e $path){
- if (-d $path){
- if (!-l $path){
-
- local* THEDIR;
- my $file;
-
- opendir THEDIR, $path;
-
- while ($file = readdir THEDIR){
- if ($file ne '.' && $file ne '..'){
- deleteTree($path . "/" . $file);
- }
- }
-
- closedir THEDIR;
-
- rmdir $path;
- } else {
- unlink $path;
- }
- } else {
- unlink $path;
- }
- } else {
- if (-l $path)
- {
- unlink $path;
- }
- }
- }
-